package edu.hitsz.aircraft;

import edu.hitsz.application.Main;
import edu.hitsz.factory.prop.BloodPropFactory;
import edu.hitsz.factory.prop.BombPropFactory;
import edu.hitsz.factory.prop.BulletPropFactory;
import edu.hitsz.prop.AbstractProp;
import edu.hitsz.shoot.ShootDirectByEnemy;
import edu.hitsz.shoot.ShootDirectByHero;

import java.util.Random;

/**
 * 精英敌机
 * 可以射击
 * 被击败后会掉落道具
 * @author hitsz
 */

public class EliteAircraft extends AbstractAircraft {


    public EliteAircraft(int locationX, int locationY, int speedX, int speedY, int hp) {
        super(locationX, locationY, speedX, speedY, hp);
        this.type = 2;
        this.shootStrategy = new ShootDirectByEnemy();
        this.shootNum = 1;
        this.power = 5;
        this.direction = 1;
    }

    @Override
    public void forward() {
        super.forward();
        // 判定 y 轴向下飞行出界
        if (locationY >= Main.WINDOW_HEIGHT ) {
            vanish();
        }
    }

    @Override
    public AbstractProp dropProp() {
        Random r = new Random();

        int choice = r.nextInt(5);
        AbstractProp newProp = null;

        if (choice == 0) {
            newProp = new BloodPropFactory().createProp(
                    this.locationX,
                    this.locationY,
                    0,
                    10
            );
        } else if (choice <= 3) {
            newProp = new BombPropFactory().createProp(
                    this.locationX,
                    this.locationY,
                    0,
                    10);
        } else if (choice > 3) {
            newProp = new BulletPropFactory().createProp(
                    this.locationX,
                    this.locationY,
                    0,
                    10);
        }
        return newProp;
    }

    @Override
    public void explode() {
        this.vanish();
    }
}
